<%@ taglib prefix="c"   uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@page import="org.apache.commons.beanutils.locale.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet"  href="<%=request.getContextPath()%>/css/display.css" type="text/css" media="screen" />
<script src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script src="<%=request.getContextPath()%>/js/autocomplete.js"></script>
<script src="<%=request.getContextPath()%>/js/form.js"></script> 
<script type="text/javascript" src='<%=request.getContextPath()%>/js/input01.js'></script>

<title>Gestione Auser - Fornitori</title>

</head>
<body> 
	 
	 <form method="post" action="save.jsp" name="formFornitori" id=""formFornitori"">
		 <c:if test="${empty param.id}" >
		 	<h1>Aggiunta di un fornitore</h1>   
		 	<input type="hidden" name="EditMode" value="ADD" />
		 </c:if>
		 
		 <c:if test="${!empty param.id}" >
		 	<h1>Dati fornitore</h1> 
		 	<input type="hidden" name="EditMode" value="EDIT" />
		 </c:if>
		 
		 
		<fieldset>
			<legend>Dati principali</legend>  
	 		
	 		<label for='ragioneSociale'>Ragione Sociale</label><input type="text" name="ragioneSociale" id="ragioneSociale" size="60" value="${editFornitore.ragioneSociale}" /> 
	 		<label class='validError'>${eRagioneSociale}</label><br/>
	 			
	 		<label for='codicePianoConti'>Codice Piano dei conti</label>	
	 		<input  class="autocomplete" size="13" id="codicePianoConti" name="codicePianoConti" value="${editFornitore.codicePianoConti}">
	 		<br>
	 			 		
	 		 <label for='indirizzo'>Indirizzo</label><input type="text" name="indirizzo" id="indirizzo"  size="45" value="${editFornitore.indirizzo}" /><br/>
	 		<label for='comune'>Comune residenza</label><input type="text" name="comune" id="comune"  size="45" value="${editFornitore.comune}" /><br/>
	 		<div class='howtomsg'>Dopo aver digitato i primi tre caratteri compare la lista dei comuni</div><br>
	 		<label for='cap'>Cap</label><input type="text" name="cap" id="cap"  size="6" value="${editFornitore.cap}" /><br/>
	 		<label for='provincia'>Provincia</label><input type="text" name="provincia" id="provincia"  size="5" value="${editFornitore.provincia}" /><br/>
	 					
			<label for='piva'>P.iva</label><input type="text" name="piva" id="piva"  size="20" value="${editFornitore.piva}" /><br/>
			
			<label for='telefono'>Telefono</label><input type="text" name="telefono" id="telefono" size="45" value="${editFornitore.telefono}" /><br>
			<label for='cellulare'>Cellulare</label><input type="text" name="cellulare" id="cellulare" size="45" value="${editFornitore.cellulare}" /><br>
			<label for='fax'>Fax</label><input type="text" name="fax" id="fax" size="45" value="${editFornitore.fax}" /><br>
			<label for='email'>E-mail</label><input type="text" name="email" id="email" size="45" value="${editFornitore.email}" /><br>
			
			<br>
			<input style='float:right' class='button' type='button' value='Esci senza salvare' id='btnClose' onclick='document.location="<%=request.getContextPath()%>/app/start/index.jsp"'> 
	 		<input style='float:right' class='button' type='submit' value='Salva' id='btnSave' />		
		</fieldset>	
	 		
	<script>
		function selectItemComune(li) { 
			//cap,provincia,istat,catastale
			if (li.extra) {
				$("#cap").val(li.extra[0]); 
				$("#provincia").val(li.extra[1]); 
				$("piva").focus();
			}	
		}
		 
		function selectItemFornitore(li) { 
			//cap,provincia,istat,catastale
			if (li.extra) { 
			}	
		} 
		
		function formatItemCont(row) { 	 
			return "<span style='width:2cm'><b>" + row[0]+"</b></span> - "+row[1];
		}
		
		function formatItem(row) {
			return "<b>" + row[0]+"</b> (" + row[2] + ")";
		}
		
		$(function(){	 
			$("#comune").autocomplete("<%=request.getContextPath()%>/app/comuni/lookup.jsp", { minChars:3,  matchContains:1, cacheLength:30, onItemSelect:selectItemComune, formatItem:formatItem, selectOnly:1 });
			$("#codicePianoConti").autocomplete("<%=request.getContextPath()%>/app/pconti/lookupfornitori.jsp", { minChars:1,  matchContains:1, cacheLength:30, onItemSelect:selectItemFornitore, formatItem:formatItemCont, selectOnly:1 });
			
		});
	</script>
	
</body>
</html>